package com.xkcyy.one.controller;

import com.xkcyy.one.common.Result;
import com.xkcyy.one.entity.TrainingLog;
import com.xkcyy.one.service.TrainingLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 训练日志控制器
 */
@RestController
@RequestMapping("/api/training/logs")
public class TrainingLogController {
    
    private final TrainingLogService trainingLogService;
    
    @Autowired
    public TrainingLogController(TrainingLogService trainingLogService) {
        this.trainingLogService = trainingLogService;
    }
    
    /**
     * 根据会话ID获取日志列表
     *
     * @param sessionId 会话ID
     * @return 日志列表
     */
    @GetMapping("/session")
    public Result<List<TrainingLog>> getLogsBySessionId(@RequestParam Long sessionId) {
        return Result.success(trainingLogService.getLogsBySessionId(sessionId));
    }
    
    /**
     * 根据ID获取日志
     *
     * @param id 日志ID
     * @return 日志信息
     */
    @GetMapping("/get")
    public Result<TrainingLog> getLogById(@RequestParam Long id) {
        return Result.success(trainingLogService.getLogById(id));
    }
} 